package com.wn.controller;

import com.wn.bean.Constants;
import com.wn.bean.House;
import com.wn.bean.PropertyType;
import com.wn.bean.R;
import com.wn.service.IPropertyTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yellow Docter
 * @since 2022-05-24
 */
@RestController
@RequestMapping("/propertyType")
public class PropertyTypeController {

    @Autowired
    private IPropertyTypeService propertyTypeService;

    @GetMapping("/all")
    public R queryHouseAll(){

        List<PropertyType> list = propertyTypeService.list();

        // 组装数据返回结果
        R r = new R();

        if (!CollectionUtils.isEmpty(list)){
            r.setData(list);
            r.setMsg("查询成功");
            r.setCode(Constants.SUCCESS_CODE);
            return r;
        }
        return R.ERROR("查询失败");
    }

}
